/*  

Cafechess Library: Cover basic chess programming needs, like GUI, Engine integration, 
FEN and PGN parsing.

                 \\|//
                 (o o)
--------------ooO-(_)-Ooo----------------------------------
Copyright (C) 2009  By Gregory A. Prentice Snoqualmie, WA
                    www.cafechess.org
                    cafechess@comcast.net
                      Oooo
--------------oooO----(  )---------------------------------
              (  )    (_/
               \_)

Microsoft Public License (Ms-PL)
               
Revisions:

Author        Date    Description:

*/
using System;

namespace Cafechess.Chess.Navigation
{
  /// <summary>
  /// Defines the interface necessary to implement the navigation through
  /// chess games.
  /// </summary>
  public interface IGamesNavigation
  {
    /// <summary>
    /// Returns the current game.
    /// </summary>
    IGameNavigation Game
    {
      get;
    }
    /// <summary>
    /// Returns true when we are currently at a game.
    /// </summary>
    bool IsGameOk{ get; }
    /// <summary>
    /// Should position you to the first game in the data store.
    /// </summary>
    void FirstGame();
    /// <summary>
    /// Position you to the next game in the data store.
    /// </summary>
    void NextGame();
    /// <summary>
    /// Position you to the previous game in the data store.
    /// </summary>
    void PrevGame();
    /// <summary>
    /// Positin you to the last game in the data store.
    /// </summary>
    void LastGame();
    /// <summary>
    /// Locates a game base on search infor (To Be Defined)
    /// </summary>
    void FindGame();
    /// <summary>
    /// Add the events that will get fired as we navigate through our game/s.
    /// </summary>
    /// <param name="nav"></param>
    void AddEvents(IGamesNavigationEvents nav);
    /// <summary>
    /// Removes the events so that we will stop receiving events.
    /// </summary>
    /// <param name="nav"></param>
    void RemoveEvents(IGamesNavigationEvents nav);
  }

  /// <summary>
  /// Standard interface for receiving events from the process of navigating through
  /// games.  For game movement check the INavigation.IsMoveOk before using the properties
  /// of INavigation to retrieve values.
  /// </summary>
  public interface IGamesNavigationEvents
  {
    void MovedFirstGame(IGamesNavigation nav);
    void MovedNextGame(IGamesNavigation nav);
    void MovedPrevGame(IGamesNavigation nav);
    void MovedLastGame(IGamesNavigation nav);
    void MovedFindGame(IGamesNavigation nav);
    void EndOfGames(IGamesNavigation nav);
    void BegOfGames(IGamesNavigation nav);
  }
  /// <summary>
  /// Defines the interface necessary to implement the navigation through
  /// chess games.
  /// </summary>
  public interface IGameNavigation
  {
    /// <summary>
    /// Positions you to the very first move of the game.
    /// </summary>
    void FirstMove();
    /// <summary>
    /// Positions you to the next move.
    /// </summary>
    void NextMove();
    /// <summary>
    /// Positions you to the previous move.
    /// </summary>
    void PrevMove();
    /// <summary>
    /// Positions you to the very last move of the current line.
    /// </summary>
    void LastMove();
    /// <summary>
    /// Moves through the move list until you reach the end of the current line or
    /// the next occurance of sub-variations in the move list.
    /// </summary>
    void NextLine();
    /// <summary>
    /// Moves you to the previous point in the game where you step into a variation.
    /// </summary>
    void PrevLine();
    /// <summary>
    /// Returns true when the requested action occurred successfully.
    /// </summary>
    bool IsMoveOk{ get; set; }
    /// <summary>
    /// Returns the standard algebraic move.
    /// </summary>
    string Move{ get; }
    /// <summary>
    /// Returns the current move number of the game.
    /// </summary>
    int MoveNumber{ get; }
    /// <summary>
    /// True if it is whites turn to move.
    /// </summary>
    bool IsWhitesMove{ get; }
    /// <summary>
    /// Add the events that will get fired as we navigate through our game/s.
    /// </summary>
    /// <param name="nav"></param>
    void AddEvents(IGameNavigationEvents nav);
    /// <summary>
    /// Removes the events so that we will stop receiving events.
    /// </summary>
    /// <param name="nav"></param>
    void RemoveEvents(IGameNavigationEvents nav);
  }

  /// <summary>
  /// Standard interface for receiving events from the process of navigating through
  /// games.  For game movement check the INavigation.IsMoveOk before using the properties
  /// of INavigation to retrieve values.
  /// </summary>
  public interface IGameNavigationEvents
  {
    void MovedFirstMove(IGameNavigation nav);
    void MovedNextMove(IGameNavigation nav);
    void MovedPrevMove(IGameNavigation nav);
    void MovedLastMove(IGameNavigation nav);
    void MovedNextLine(IGameNavigation nav);
    void MovedPrevLine(IGameNavigation nav);
    void EndOfLine(IGameNavigation nav);
    void BegOfLine(IGameNavigation nav);
    /// <summary>
    /// Fired when the UI needs to ask the user which sub-variation we
    /// need to navigate into.
    /// </summary>
    /// <param name="nav"></param>
    /// <returns>
    /// A value from 0 to number of variations available, users choice of which
    /// line to enter.  A minus value signals cancel selection.
    /// </returns>
    int  EnterVariation(IGameNavigation nav);
  }

}
